import dayjs from 'dayjs'

const pickerOptions = {
  disabledDate(time) {
    // debugger
    return time.getTime() > Date.now()
  },
  'default-time': ['00:00:00', '23:59:59'],
  shortcuts: [{
    text: '昨天',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 1)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近一周',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近30天',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      picker.$emit('pick', [start, end])
    }
  }, {
    text: '最近90天',
    onClick(picker) {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
      picker.$emit('pick', [start, end])
    }
  }]
}

const pickerOptions2 = {
  disabledDate(time) {
    // debugger
    console.log(time, time.getDay())
    let returnData = false
    if ((time.getDay() !== 5) || ((time.getTime() > Date.now()))) {
      if (time.getDay() === 5 && time.getDate() === 31) {
        console.log(time)
        returnData = true
      }
      returnData = true
    }
    return (returnData)
  },
  'default-time': ['00:00:00', '23:59:59']
}
const pickerOptions3 = {
  disabledDate(time) {
    // debugger
    return time.getTime() > Date.now()
  },
  'default-time': ['00:00:00', '23:59:59']
}
const today = dayjs().format('YYYY-MM-DD 00:00:00')
const tomonth = dayjs().format('YYYY-MM-01')
const pickTime = [dayjs().subtract(7, 'days').format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD')]
const pickTime1 = [dayjs().format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD')]
const pickTimeOne = [dayjs().format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD')]
const pickTimeLast = ['2017-01-01', dayjs().format('YYYY-MM-DD')]

//---------

const yesterday = dayjs().subtract(1, 'day').format('YYYY-MM-DD 00:00:00')
const lastmonth = dayjs().subtract(1, 'month').format('YYYY-MM-01')
export { pickerOptions, pickTime, pickTime1, pickTimeOne, pickTimeLast, pickerOptions2, today, pickerOptions3, tomonth,yesterday,lastmonth}
